package com.dataeco.api.dto.helper;

import com.dataeco.api.dto.UserInfo;
import com.dataeco.api.entity.User;
import com.dataeco.api.utils.IDUtils;

public class UserHelper {


    public UserInfo convertUserEntityToUserInfo(User user){
        UserInfo userInfo=new UserInfo();
        userInfo.setId(user.getId());
        userInfo.setCompany(user.getCompany());
        userInfo.setContact(user.getContact());
        userInfo.setEmail(user.getEmail());
        userInfo.setQq(user.getQq());
        userInfo.setTelephone(user.getTelephone());
        userInfo.setWebsite(user.getWebsite());
        return userInfo;
    }
    public User convertUserInfoToUserEntity(UserInfo userInfo){
        User user=new User();
        if (!("".equals(userInfo.getWebsite()))&&!(null==userInfo.getWebsite())){
            user.setWebsite(userInfo.getWebsite());
        }
        if (!("".equals(userInfo.getTelephone()))&&!(null==userInfo.getTelephone())){
            user.setTelephone(userInfo.getTelephone());
        }
        if (!("".equals(userInfo.getQq()))&&!(null==userInfo.getQq())){
            user.setQq(userInfo.getQq());
        }
        if (!("".equals(userInfo.getContact()))&&!(null==userInfo.getContact())){
            user.setContact(userInfo.getContact());
        }
        user.setUsername(IDUtils.uuid32());
        user.setCompany(userInfo.getCompany());
        user.setEmail(userInfo.getEmail());
        user.setPassword(userInfo.getPassword());
        return user;
    }
}
